package com.ts.boot.util;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;

import java.util.Date;

public class Test {

    public static void main(String[] args) {

        String date = DateUtil.format(DateUtil.parse("2021-03-01"),"yyyy-MM-dd");
        System.out.println(date);
        DateTime date2 = DateUtil.date();
        System.out.println(date2);
        DateTime newDate = DateUtil.offset(date2.toJdkDate(), DateField.DAY_OF_MONTH,27);
        System.out.println(newDate.toString());
        String date3 = DateUtil.format(DateUtil.parse("2021-10-10 10:23:13"),"yyyy-MM-dd");
        System.out.println(date3);

        System.out.println("下一天：" + getDateNext("2021-02-28"));
        String startDate = "2021-03-01";
        String endDate = "2021-03-03";
        System.out.println(endDate.equals(getDateNext(startDate)));
    }

    public static String getDateNext(String date){

        return DateUtil.offset(DateUtil.parseDate(date), DateField.DAY_OF_MONTH,1).toString().substring(0,10);
    }
}
